import {IProject} from "@/store/pojo/IProject";
import axios from "axios";
import router from "@/router";

const createProject = async (project: IProject) => {
    const publisherId = project.publisherId;
    const projectName = project.projectName;
    const particleSize = project.particleSize;
    const target = project.target;
    const deadline = project.deadline;
    const fps = project.fps;

    const data = {
        id: null,
        publisherId,
        adminId: null,
        projectName,
        resourcePath: null,
        resultPath: null,
        particleSize,
        target,
        deadline,
        status: -1,
        checked: null,
        fps
    }


    const url = "/api/project/create";
    axios.post(url, data)
        .then(function (response) {
            console.log(response);
            if (response.data != "") {
                sessionStorage.setItem("project.id", response.data.id);
                alert("创建任务成功,请上传文件");
                router.push("/user/publisher/workspace/upload");
            } else {
                alert("创建任务失败，请重新输入")
                router.push("/user/publisher/workspace");
            }
        })

}
export default createProject;